﻿using System.Collections.Generic;
using System.Linq;
using PTop.Domain.Entity.Questionnaire;

namespace PTop.Front.Areas.Qn.Models
{
    public class QnPaperModel
    {
        public QnPaperEntity QnPaper { get; set; }

        public QnQuestionEntity[] QnQuestions { get; set; }

        public QnAnswerEntity[] QnAnswers { get; set; }

        public string QnAnswersStr
        {
            get
            {
                if (QnAnswers == null || !QnAnswers.Any()) return "";
                var answers = new List<string>();
                for (var i = 0; i < QnQuestions.Length; i++)
                {
                    var question = QnQuestions[i];
                    var answer = QnAnswers.First(m => m.F_QuestionId == question.F_Id);
                    answers.Add((i + 1) + ":" + answer.F_Answer);
                }
                return string.Join(";", answers);
            }
        }

        public bool HasAnswered { get; set; }
    }
}